<!doctype html>
<html class="no-js">

<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>党建网</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="../../assets/css/amazeui.css" />
<link rel="stylesheet" href="../../assets/css/admin.css">
<link rel="stylesheet" href="../../css/amazeui.datetimepicker.css" />
<link rel="stylesheet" href="../../css/addMember.css" />

</head>

<body>
	<!--[if lte IE 9]>
<p class="browsehappy">你正在使用<strong>过时</strong>的浏览器，Amaze UI 暂不支持。 请 <a href="http://browsehappy.com/" target="_blank">升级浏览器</a>
  以获得更好的体验！</p>
<![endif]-->

	<header class="am-topbar amt-header"> </header>

	<div class="am-cf">
		<!-- sidebar start -->
		<div class="admin-sidebar am-offcanvas" id="admin-offcanvas"></div>
		<!-- sidebar end -->

		<!-- content start -->
		<div class="admin-content">
			<div class="admin-content-body">
				<div class="am-cf am-padding" style="margin-left: 2%">
					<div class="am-fl am-cf">
						<strong class="am-text-primary am-text-lg" style="color: #BD2D30">党员信息</strong>
					</div>
				</div>

				<form class="am-form am-form-horizontal">
					<div class="left-div">
						<div class="am-g am-margin-top">
							<div class="am-u-sm-4 am-u-md-4 am-text-right">
								<b> 姓名</b>
							</div>
							<div class="am-u-sm-8 am-u-md-7 am-u-end col-end">
								<input type="text" class="am-input-sm" id="name">
							</div>
						</div>
						<div class="am-g am-margin-top">
							<div class="am-u-sm-4 am-u-md-4 am-text-right">
								<b> 工作</b>
							</div>
							<div class="am-u-sm-8 am-u-md-7 am-u-end col-end">
								<input type="text" class="am-input-sm" id="job">
							</div>
						</div>
						<div class="am-g am-margin-top">
							<div class="am-u-sm-4 am-u-md-4 am-text-right">
								<b> 出生年月</b>
							</div>
							<div class="am-u-sm-8 am-u-md-7 am-u-end col-end">
								<div class="am-input-group am-datepicker-date">
									<input type="text" class="am-form-field" id="birth"
										class="Wdate" onClick="WdatePicker({dateFmt: 'yyyy-MM-dd'})"
										required /> <span class="am-input-group-label add-on"><i
										class="icon-th am-icon-calendar"></i></span>
								</div>
							</div>
						</div>
						<div class="am-g am-margin-top">
							<div class="am-u-sm-4 am-u-md-4 am-text-right">
								<b> 入党日期</b>
							</div>
							<div class="am-u-sm-8 am-u-md-7 am-u-end col-end">
								<div class="am-input-group am-datepicker-date">
									<input type="text" class="am-form-field" id="join"
										class="Wdate" onClick="WdatePicker({dateFmt: 'yyyy-MM-dd'})"
										required /> <span class="am-input-group-label add-on"><i
										class="icon-th am-icon-calendar"></i></span>
								</div>
							</div>
						</div>
					</div>
					<div class="right-div">
						<div class="am-g am-margin-top">
							<div class="am-u-sm-4 am-u-md-3 am-text-right">
								<b>性别</b>
							</div>
							<div class="am-u-sm-8 am-u-md-8 am-u-end col-end">
								<label class="am-radio-inline am-danger"
									style="padding-top: -0.6em"> <input type="radio"
									name="gender" value="1" data-am-ucheck />男
								</label>&nbsp; <label class="am-radio-inline am-danger"> <input
									type="radio" name="gender" value="0" data-am-ucheck />女
								</label>

							</div>
						</div>
						<div class="am-g am-margin-top">
							<div class="am-u-sm-4 am-u-md-3 am-text-right">
								<button type="button" class="am-btn am-btn-xs am-btn-primary"
									id="head_btn"
									style="background: #BD2D30; border-color: #BD2D30;">上传头像</button>

							</div>
							<div class="am-u-sm-8 am-u-md-8 am-u-end col-end">
								<div class="img-head">
									<div style="display: none">
										<p>
											<input type="file" id="head_file_ipt" name="image"
												onChange="ajaxFileUpload();" accept="image/*" />
										</p>
									</div>
									<img id="img_tx" src="../../img/tx.png" alt="头像"
										style="width: 100%; height: 100%"
										class="am-img-thumbnail am-circle">
								</div>
							</div>
						</div>

					</div>

					<div class="button-div">
						<div class="am-form-group">
							<div class="am-u-sm-4 am-u-md-2 am-text-right"
								style="padding-top: 0.6em">
								<b>党员介绍</b>
							</div>
							<div class="am-u-sm-10 am-u-end col-end"
								style="padding-top: 10px">
								<script id="editor" type="text/plain"
									style="width: 100%; height: 500px;"></script>
							</div>
						</div>
						<div class="am-g" style="margin-top: 10px">
							<div class="am-u-sm-12 am-u-sm-centered"
								style="text-align: right">
								<button type="button" class="am-btn am-btn-primary" id="pub_btn"
									style="background: #BD2D30; border-color: #BD2D30">更新</button>
								<button type="button" class="am-btn am-btn-primary" id=""
									style="background: #BD2D30; border-color: #BD2D30; margin-left: 1%">取消</button>
							</div>
						</div>
					</div>
				</form>

			</div>


		</div>
		<!-- content end -->

	</div>

	<a href="#" class="am-show-sm-only admin-menu"
		data-am-offcanvas="{target: '#admin-offcanvas'}"> <span
		class="am-icon-btn am-icon-th-list"></span>
	</a>


	<!--[if lt IE 9]>
<script src="http://libs.baidu.com/jquery/1.11.1/jquery.min.js"></script>
<script src="http://cdn.staticfile.org/modernizr/2.8.3/modernizr.js"></script>
<script src="/assets/js/amazeui.ie8polyfill.min.js"></script>
<![endif]-->

	<!--[if (gte IE 9)|!(IE)]><!-->
	<script src="../../assets/js/jquery.min.js"></script>
	<!--<![endif]-->
	<script src="../../assets/js/amazeui.min.js"></script>
	<script src="../../js/left-nav.js"></script>
	<script src="../../js/header.js"></script>
	<script type="text/javascript" charset="utf-8"
		src="../../ueditor/ueditor.config.js"></script>
	<script type="text/javascript" charset="utf-8"
		src="../../ueditor/ueditor.all.min.js"></script>
	<script type="text/javascript" charset="utf-8"
		src="../../ueditor/lang/zh-cn/zh-cn.js"></script>
	<script type="text/javascript" charset="utf-8"
		src="../../js/amazeui.datetimepicker.min.js"></script>
	<script type="text/javascript" charset="utf-8"
		src="../../js/bootstrap-datetimepicker.zh-CN.js"></script>
	<script type="text/javascript"
		src="../../js/My97DatePicker/WdatePicker.js"></script>
	<script src="../../js/index.js"></script>
	<script src="../../js/global.js"></script>

	<script type="text/javascript">
		$(document).ready(function() {
			$("#collapse-nav-2").addClass("am-in");

			var pkPm = getCookie("pkPm");
			$.ajax({
				type : "GET",
				url : "/partyBuilding/partyMem/" + pkPm,
				contentType : "application/json",
				dataType : "json",
				success : function(data) {
					//alert(JSON.stringify(data));
					if (data.code == "200") {
						view(data);
					}
				},
				error : function() {

				}
			});

		})

		function view(data) {
			var data = data.partyMem;
			$("#name").val(data.pmName);
			$("#birth").val(getDate(data.pmBirthDate));
			$("#join").val(getDate(data.pmJoinDate));
			$("#job").val(data.pmJob);
			$("#img_tx").attr('src', data.pmPhotoUrl);
			//alert(data.pmGender);
			if (data.pmGender == false) {
				$('input[name="gender"]:eq(1)').attr("checked", 'checked');
			} else {
				$('input[name="gender"]:eq(0)').attr("checked", 'checked');
			}
			var ue = UE.getEditor('editor');
			ue.addListener("ready", function() {
				// editor准备好之后才可以使用
				ue.setContent(data.pmIntro);

			});

		}

		/*   更新信息 */

		$("#pub_btn").click(function() {
			var content = {};

			var pkPm = getCookie("pkPm");
			content["pkPm"] = pkPm;
			var pmPhotoUrl = $("#img_tx").attr("src");
			content["pmPhotoUrl"] = pmPhotoUrl;
			//alert(pmPhotoUrl);

			var pmGender = getRadioValue("gender");
			if (pmGender == 1) {
				content["pmGender"] = true;
			} else {
				content["pmGender"] = false;
			}

			//姓名
			var pmName = $("#name").val();
			if (pmName == "") {
				alertModal("提示", "姓名不能为空");
				return false;
			}
			content["pmName"] = pmName;

			var pmJob = $("#job").val();
			if (pmJob == "") {
				alertModal("提示", "工作不能为空");
				return false;
			}
			content["pmJob"] = pmJob;

			//出生年月
			var pmBirthDate = $("#birth").val();
			if (pmBirthDate == "") {
				alertModal("提示", "出生年月不能为空");
				return false;
			}
			content["pmBirthDate"] = pmBirthDate;

			var pmJoinDate = $("#join").val();
			if (pmJoinDate == "") {
				alertModal("提示", "入党日期不能为空");
				return false;
			}
			content["pmJoinDate"] = pmJoinDate;
			// 正文
			var ue = UE.getEditor('editor');
			var pmIntro = ue.getContent();
			if (pmIntro == "") { // 若公告链接未填写，需检查正文内容是否为空
				alertModal("提示", "正文内容为空");
				return false;
			} else {
				content["pmIntro"] = pmIntro;
				//alert(JSON.stringify(content));
				saveNews(content);
			}

		});

		/* 保存公告 */
		function saveNews(content) {
			$.ajax({
				type : "PUT",
				url : "/partyBuilding/partyMem",
				data : encrypt(content),
				contentType : "application/json",
				dataType : "json",
				success : function(data) {
					ALERT(JSON.stringify(data));
					if (data.code == "200") {
						alertModal("提示", "修改成功", function() {
						});
					} else {
						alertModal("警告", data.msg);
					}
				},
				error : function() {
					alertModal("警告", "服务器开小差了");
				}
			});
		}

		/* $("#birth").focus(function(){
			$("#birth").html("");
		}) */
		/* 上传头像按钮点击事件 */
		$("#head_btn").on("click", function() {
			$("#head_file_ipt").trigger("click");
		})
		/* 文件上传 */
		var userHeadUrl;
		function ajaxFileUpload() {
			$.ajaxFileUpload({
				url : '/partyBuilding/files/pmPhoto', //用于文件上传的服务器端请求地址
				secureuri : false, //是否需要安全协议，一般设置为false
				fileElementId : 'head_file_ipt', //文件上传域的ID
				dataType : 'json', //返回值类型 一般设置为json
				success : function(data) { //服务器成功响应处理函数
					ALERT(JSON.stringify(data));
					if (data.code == 200) {
						userHeadUrl = data.userHeadUrl;
						alertModal("提示", "上传成功", function() {
							//alert(userHeadUrl);
							//$("#adminHead").html('<img class="am-circle am-img-thumbnail img_1" src="'+ userHeadUrl +'" />');
							$("#img_tx").attr('src', userHeadUrl);
						});
					}
				},
				error : function(data, status, e) { //服务器响应失败处理函数
					handleAjaxError();
				}
			});
		}
	</script>
</body>

</html>